#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Solution {
public:
    string longestCommonPrefix_1(vector<string> &strs)
    {
        if (!strs.size()) {
            return "";
        }
        string prefix = strs[0];
        int count = strs.size();
        for (int i = 1; i < count; ++i) {
            prefix = longestCommonPrefix_1(prefix, strs[i]);
            if (!prefix.size()) {
                break;
            }
        }
        return prefix;
    }

    string longestCommonPrefix_1(const string &s1, const string &s2)
    {
        int length = min(s1.size(), s2.size());
        int index = 0;
        while (index < length && s1[index] == s2[index]) {
            ++index;
        }
        return s1.substr(0, index);
    }

    string longestCommonPrefix_2(vector<string> &strs)
    {
        if (!strs.size()) {
            return "";
        }
        int length = strs[0].size();
        int count = strs.size();
        for (int i = 0; i < length; ++i) {
            char c = strs[0][i];
            for (int j = 1; j < count; ++j) {
                if (i == strs[j].size() || strs[j][i] != c) {
                    return strs[0].substr(0, i);
                }
            }
        }
        return strs[0];
    }
};

int main()
{
    cout << "Hello World!" << endl;
    return 0;
}
